package com.wang.mylambda;

import java.util.function.Function;

/**
 * @author yandong
 */
public class LambdaDemo4 {
    public static void main(String[] args) {
        // 传统写法: 匿名内部类
        typeConvert(new Function<String, Integer>() {
            @Override
            public Integer apply(String s) {
                return Integer.valueOf(s);
            }
        });

        // Lambda表达式写法:
        typeConvert(s -> Integer.valueOf(s));
    }
    public static <R> void typeConvert(Function<String, R> function) {
        String str = "1235";
        System.out.println(function.apply(str));
    }
}
